<?php

namespace app\api\model;

use think\Model;

class GroupApply extends Model
{

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';


    public function getList($group_id)
    {
        $data = $this->alias('a')
            ->join('user_info b', 'a.user_id = b.user_id')
            ->where('a.group_id', $group_id)
            ->field('b.user_id,b.username,b.avatar,b.status as auth_status,b.birthday,b.gender')
            ->paginate(10);
        foreach ($data as $k => $v) {
            $data[$k]['members'] = model('members')->where('user_id', $v['user_id'])->value('status') ?? 0;
            $data[$k]['age'] = user_age($v['birthday']);//年龄
        }
        return $data;
    }
}